-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[rllib] Update flatten_observations.py for nested spaces for ignored multi-agent #59928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rllib] Update flatten_observations.py for nested spaces for ignored multi-agent #59928
Conversation
…ent situations Signed-off-by: Mark Towers <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a bug in the FlattenObservations connector for multi-agent scenarios with nested observation spaces. The core fix correctly preserves the original observation space for agents whose observations are not flattened, which is crucial for nested spaces. The changes are well-implemented and include several improvements: a new multi-agent example in the docstring that clearly demonstrates the fix, added type hints for better readability, and new assertions that enhance the robustness of the code by validating space types. The docstring for the __init__ method has also been updated for better clarity. Overall, this is a high-quality contribution that not only fixes the bug but also improves the code's maintainability and documentation.
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
…multi-agent (ray-project#59928) ## Description For the FlattenObservation connector, in the mutli-agent case, if any of the agent's had a nested space, if it was ignored then we used the base_struct version of the observation_spaces rather than the actual spaces which for nested spaces is a problem. FYI, I believe that `get_base_struct_from_space` can be removed as Gymnasium has added the ability to treat `Dict` and `Tuple` spaces as like a dict or tuple for iterating, calling `.keys()`, `.values()` and `.items()`. For a future PR possibly ## Related issues Fixes ray-project#59849 --------- Signed-off-by: Mark Towers <[email protected]> Signed-off-by: Artur Niederfahrenhorst <[email protected]> Co-authored-by: Mark Towers <[email protected]> Co-authored-by: Artur Niederfahrenhorst <[email protected]> Co-authored-by: Artur Niederfahrenhorst <[email protected]> Signed-off-by: jasonwrwang <[email protected]>
Description
For the FlattenObservation connector, in the mutli-agent case, if any of the agent's had a nested space, if it was ignored then we used the base_struct version of the observation_spaces rather than the actual spaces which for nested spaces is a problem.
FYI, I believe that
get_base_struct_from_spacecan be removed as Gymnasium has added the ability to treatDictandTuplespaces as like a dict or tuple for iterating, calling.keys(),.values()and.items(). For a future PR possiblyRelated issues
Fixes #59849